﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

using global::FluentValidation;
using global::FluentValidation.TestHelper;

namespace ERPStore.Validation.FluentValidation.Tests
{
	[TestFixture]
	public class ModelValidatorTests : ERPStore.Tests.TestBase
	{
		[SetUp]
		public override void Initialize()
		{
			base.Initialize();
		}

		[Test]
		public void Empty_ContactInfo()
		{
			var contactInfo = new Models.ContactInfo();
			var validator = new ERPStore.ModelValidators.ContactInfoValidator();

			var result = validator.Validate(contactInfo);

			Assert.AreEqual(result.IsValid, false);
		}

		[Test]
		public void Invalid_ContactInfo()
		{
			var contactInfo = new Models.ContactInfo();
			contactInfo.Email = "test";
			contactInfo.PhoneNumber = "test";
			var validator = new ERPStore.ModelValidators.ContactInfoValidator();

			var result = validator.Validate(contactInfo);

			Assert.AreEqual(result.IsValid, false);
		}

		[Test]
		public void Valid_ContactInfo()
		{
			var contactInfo = new Models.ContactInfo();
			contactInfo.Email = "test@test.com";
			contactInfo.PhoneNumber = "0102030405";
			contactInfo.Message = "message";
			contactInfo.FullName = "FullName";

			var validator = new ERPStore.ModelValidators.ContactInfoValidator();

			var result = validator.Validate(contactInfo);

			Assert.AreEqual(result.IsValid, true);
		}

		[Test]
		public void Empty_Address()
		{
			var address = new Models.Address();

			var validator = new ERPStore.ModelValidators.AddressValidator();
			var result = validator.Validate(address);

			Assert.AreEqual(result.IsValid, false);
		}

		[Test]
		public void Invalid_Address()
		{
			var address = new Models.Address();
			address.RecipientName = "test";
			address.City = "test";
			address.Street = "test";
			address.ZipCode = "012345";
			address.CountryId = ERPStore.Models.Country.FRA.Id;

			var validator = new ERPStore.ModelValidators.AddressValidator();
			var result = validator.Validate(address);

			Assert.AreEqual(result.IsValid, false);
		}

		[Test]
		public void Valid_Address()
		{
			var address = new Models.Address();
			address.RecipientName = "test";
			address.City = "test";
			address.Street = "test";
			address.ZipCode = "01234";

			var validator = new ERPStore.ModelValidators.AddressValidator();
			var result = validator.Validate(address);

			Assert.AreEqual(result.IsValid, true);
		}

		//[Test]
		//public void Empty_OrderCart()
		//{
		//    var cart = new Models.OrderCart();

		//    var validator = new ERPStore.Validation.FluentValidation.ModelValidators.OrderCartValidator();
		//    var result = validator.Validate(cart);

		//    Assert.AreEqual(result.IsValid, false);
		//}

		[Test]
		public void Empty_RegistrationUser()
		{
			var registrationUser = new Models.RegistrationUser();

			var validator = new ERPStore.ModelValidators.RegistrationUserValidator();
			var result = validator.Validate(registrationUser);

			Assert.AreEqual(result.IsValid, false);
		}

	}
}
